﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FerrScript
{
    class CompiledFunction
    {
        #region Fields
        internal string              name;
        internal CompilerInstruction rootInstruction;
        internal ScriptVariable[]    arguments;
        #endregion

        #region Constructor
        public CompiledFunction(string aName, CompilerInstruction aRootInstruction)
        {
            name = aName;
            rootInstruction = aRootInstruction;

            int args = 0;
            if (rootInstruction.instructions != null)
            {
                while (args < rootInstruction.instructions.Length && rootInstruction.instructions[args].value.type == ScriptValueType.Variable)
                    args++;
            }

            arguments = new ScriptVariable[args];

            for (int i = 0; i < args; i++)
                arguments[i] = (ScriptVariable)rootInstruction.instructions[i].value.value;
        }
        #endregion
    }
}
